package com.settlement.system.controller;

import com.settlement.system.common.exception.ServiceException;
import com.settlement.system.model.entity.common.Brand;
import com.settlement.system.reply.ObjectDataResponse;
import com.settlement.system.service.IBaseService;
import com.settlement.system.service.IBrandService;
import com.settlement.system.model.vo.TreeJson;
import io.swagger.annotations.ApiOperation;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import jakarta.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * 品牌信息表 前端控制器
 * @author xiaochuan
 * @since 2020-04-13
 */

@RestController
@Slf4j
@RequestMapping("/brand")
public class BrandController extends BaseController<Brand> {

    @Resource
    private IBrandService brandService;

    @Override
    public IBaseService init() {
        return brandService;
    }

    @RequestMapping("/selectBrandWithBrandUnit")
    @ApiOperation("品牌查询")
    @ResponseBody
    public ObjectDataResponse selectBrandWithBrandUnit(HttpServletRequest req){
        Map<String, Object> params = buildParam(req);
        List<TreeJson> result = null;
        try {
            result = brandService.selectBrandWithBrandUnit(params);
        } catch (ServiceException e) {
            log.error("获取品牌部插件异常",e);
            return null;
        }
        return new ObjectDataResponse<List>(result);
    }


}

